from sqlalchemy.schema import Column
from sqlalchemy.types import Integer, UnicodeText
from .base import Base, role_permissions
from sqlalchemy.orm import relation

__all__ = ['Role']

class Role(Base):
    __tablename__ = 'roles'
    
    id = Column(Integer, primary_key=True)
    name = Column(UnicodeText, nullable=False)
    
    permissions = relation('Permission', lazy=False, secondary=role_permissions)
    
    def __init__(self, name):
        self.name = name
        
    def __repr__(self):
        return "<Role('%s')>" % self.name
    
    